package com.huabo.monitor.controller;


import com.hbfk.util.JsonBean;
import com.huabo.monitor.oracle.entity.TblAssesslevel;
import com.huabo.monitor.service.TblAssesslevelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.math.BigDecimal;

@RestController
@Api(value = "等级维护", tags = {"等级维护相关"})
@RequestMapping(value = "/nbkz")
public class LevelController {

    @Resource
    private TblAssesslevelService tblAssesslevelService;

    @GetMapping(value = "/gzdg/level_list")
    @ApiOperation("等级维护列表-内容页面分页功能")
    public JsonBean gzdg_level_list(@ApiParam(name = "token", value = "登录用户token", required = true) @RequestHeader("token") String token,
                                    @ApiParam(name = "pageNumber", value = "分页当前页数", required = false) @RequestParam(value = "pageNumber", required = false, defaultValue = "1") Integer pageNumber,
                                    @ApiParam(name = "pageSize", value = "每页记录数", required = false) @RequestParam(value = "pageSize", required = false, defaultValue = "15") Integer pageSize) {

        return tblAssesslevelService.findByPageBean(pageNumber, pageSize);

    }

    @GetMapping(value = "/gzdg/level_findByid")
    @ApiOperation("通过等级主键查询")
    public JsonBean levelInfo(@RequestParam(value = "asslevid", required = true) BigDecimal id) {
        return tblAssesslevelService.findById(id);
    }

    /**
     * 新增等级
     *
     * @return
     */
    @PostMapping(value = "/gzdg/level_add")
    @ApiOperation("新增等级")
    public JsonBean gzdg_levle_add(@RequestBody TblAssesslevel tblAssesslevel) {
        return tblAssesslevelService.add(tblAssesslevel);
    }

    /**
     * 修改等级
     *
     * @return
     */
    @PostMapping(value = "/gzdg/level_modify")
    @ApiOperation("修改等级")
    public JsonBean gzdg_level_modify(@RequestBody TblAssesslevel tblAssesslevel) {
        return tblAssesslevelService.update(tblAssesslevel);
    }

    /**
     * 删除等级
     * @param asslevid
     * @return
     */
    @DeleteMapping(value = "/gzdg/level_delete")
    @ApiOperation("删除等级")
    public JsonBean gzdg_level_deleteByIds(@RequestParam("asslevid") BigDecimal asslevid) {
        return tblAssesslevelService.delete(asslevid);
    }

    ;

}
